﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
#if DEBUG
using System.Diagnostics;
#endif // #if DEBUG
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

using FRL.DebtChased.Repository;
using FRL.DebtChased.Silverlight.Library;
using FRL.DebtChased.Silverlight.Library.RichContentService;
using FRL.DebtChased.WorkflowObjects;
using FRL.DebtChased.Types;

namespace FRL.DebtChased.ChaseWorkspace
{

	/// <summary>
	/// Declaration of CachedData class
	/// Singleton pattern class for storing supporting data and chase-session
	/// </summary>
	public class CachedData : CachedDataBase
	{
        /////////////////////////////////////////////////////////////
        // Temporary

        private Dictionary<int, string> _invoiceStatuses;
        public Dictionary<int, string> InvoiceStatuses
        {
            get
            {
                if (null == _invoiceStatuses)
                {
                    _invoiceStatuses = new Dictionary<int, string>() {
                        {0,"Status 0"},
                        {1,"Status 1"},
                        {2,"Status 2"},
                        {3,"Status 3"}};
                }
                return _invoiceStatuses;
            }
        }


		/////////////////////////////////////////////////////////////
		// Nested classes

		/// <summary>
		/// Declaration of ChaseSessionItem class
		/// Class describing a chase session account
		/// </summary>
		public class ChaseSessionItem : ChaseSessionItemTransport
		{

			/////////////////////////////////////////////////////////////
			// Attributes

			// TODO
			// Currently returns the first reason, but reason list could be mixed
			public string ChaseReasonAsText
			{
				get {
					if (base.ChaseReasonList.Count > 0)
						return base.ChaseReasonList[0];
					else
						return string.Empty;
				}
			}

			// TODO
			// Currently returns the first priority, but priority list could be mixed
			public int PriorityAsInt
			{
				get {
					return base.PriorityList[0];
				}

			}

		}

		/////////////////////////////////////////////////////////////
		// Attributes

		public static CachedData Singleton
		{
			get { return m_SingletonBase as CachedData; }
		}

		private ObservableCollection<ChaseSessionItem> m_chaseItems = null;
		public ObservableCollection<ChaseSessionItem> ChaseItems
		{
			get { return m_chaseItems; }
		}

		private AccountTransport m_contextAccount = null;
		public AccountTransport ContextAccount
		{
			get { return m_contextAccount; }
			set { m_contextAccount = value; }
		}

		private Dictionary<int, string> m_tradingStyleMap = null;
		public Dictionary<int, string> TradingStyleMap
		{
			get { return m_tradingStyleMap; }
		}

		private Dictionary<int, string> m_instalmentStatusMap = null;
		public Dictionary<int, string> InstalmentStatusMap
		{
			get { return m_instalmentStatusMap; }
		}

		private double m_dblCurrentInterestRate = 0;
		public double CurrentInterestRate
		{
			get { return m_dblCurrentInterestRate; }
		}

		/////////////////////////////////////////////////////////////
		// Construction

		static CachedData()
		{

			// Create the single instance
			new CachedData();

		}

		/////////////////////////////////////////////////////////////
		// Operations - Adding data loaded from server

		public void AddIncoming(ChaseWorkspaceSupportData supportData)
		{

			// Process the support data

			// Call base-class function
			base.AddIncoming(
				supportData.CurrentUser,
				supportData.CountryMap,
				supportData.ContactPositions,
				supportData.ContactTitles,
				supportData.ContactCounties,
				supportData.BankNames
			);

			// Update trading style map
			m_tradingStyleMap = supportData.TradingStyleMap;

			// Instalment status list
			m_instalmentStatusMap = supportData.InstalmentStatusMap;

			// Retain interest rate
			m_dblCurrentInterestRate = supportData.InterestRate;

		}

		public void AddIncoming( ObservableCollection<ChaseSessionItemTransport> accountTransportList )
		{

			// Create or clear the list
			if (m_chaseItems == null)
				m_chaseItems = new ObservableCollection<ChaseSessionItem>();
			else
				m_chaseItems.Clear();

			// Load the list
			foreach (ChaseSessionItemTransport item in accountTransportList)
			{

				// Translate transport object into ChaseSessionItem
				m_chaseItems.Add(new ChaseSessionItem()
				{
					AccountId = item.AccountId,
					FRLAccountRef = item.FRLAccountRef,
					TotalAsText = item.TotalAsText,
					PriorityList = item.PriorityList,
					ChaseReasonList = item.ChaseReasonList
				});
			}

		}

		public void AddIncoming(AccountTransport account)
		{

			// Update the country map
			m_contextAccount = account;

		}

		/////////////////////////////////////////////////////////////
		// Operations - Chase Session

		public int FindOffsetByAccountId(int iAccountId)
		{

			// Shortcuts
			if (m_chaseItems == null)
			{
#if DEBUG
				Debug.Assert(false);
#endif // #if DEBUG
				return -1;
			}

			// Declare return variable
			int iFtmp = -1;

			// Loop through accounts
			for (int i1 = 0; i1 < m_chaseItems.Count; i1++)
			{
				if (m_chaseItems[i1].AccountId == iAccountId)
				{
					iFtmp = i1;
					break;
				}
			}

			// Return variable
			return iFtmp;

		}

		public ChaseSessionItem FindChaseItemByAccountId(int iAccountId)
		{

			// Shortcuts
			if (m_chaseItems == null)
			{
#if DEBUG
				Debug.Assert(false);
#endif // #if DEBUG
				return null;
			}

			// Declare return variable
			ChaseSessionItem Ftmp = null;

			// Loop through accounts
			for (int i1 = 0; i1 < m_chaseItems.Count; i1++)
			{
				if (m_chaseItems[i1].AccountId == iAccountId)
				{
					Ftmp = m_chaseItems[i1];
					break;
				}
			}

			// Return variable
			return Ftmp;

		}

		/////////////////////////////////////////////////////////////
		// Static Operations

#if USEFAKEDATA
		public static ObservableCollection<ChaseSessionItemTransport> GetDummyChaseSessionItemTransportList()
		{

			// Declare return variable
			ObservableCollection<ChaseSessionItemTransport> Ftmp = new ObservableCollection<ChaseSessionItemTransport>();

			// Add the chase accounts
			for (int iAccountId = 1; iAccountId <= 10; iAccountId++)
			{

				// Get the account transport
				AccountTransport acc = GetDummyAccountTransport(iAccountId);

				// Add up the invoices
				List<Money> moneyList = new List<Money>();
				foreach (AccountInvoiceTransport accInv in acc.AccountInvoices)
					moneyList.Add( new Money(accInv.Amount.Amount, accInv.Amount.CurrencyCode) );
				string strTotal = Money.SuperSmartAddition(moneyList,true);

				// Add new chase session
				ChaseSessionItemTransport chaseSession = new ChaseSessionItemTransport() {
					AccountId = iAccountId, 					
					FRLAccountRef = acc.FRLReference, 
					TotalAsText = strTotal, 
				};
				Ftmp.Add(chaseSession);

				// Add chase reasons
				chaseSession.ChaseReasonList = new ObservableCollection<string>();
				chaseSession.ChaseReasonList.Add("Chase Debt");

				// Get priorty
				int iPriorty = (int)WorkflowAction_Base.ePriority.Medium;
				if (iAccountId <= 3)
					iPriorty = (int)WorkflowAction_Base.ePriority.Low;
				else if (iAccountId >= 7)
					iPriorty = (int)WorkflowAction_Base.ePriority.High;
				chaseSession.PriorityList = new ObservableCollection<int>();
				chaseSession.PriorityList.Add(iPriorty);

			}

			// return object
			return Ftmp;

		}
#endif // #if USEFAKEDATA

#if USEFAKEDATA
		public static AccountTransport GetDummyAccountTransport(int iAccountId)
		{

			// Encoded dummay account data provided in spreadsheet by FRL staff

			// Get dummy client
			ClientTransport dummyClient = CachedDataBase.GetDummyClientTransport();

			// Declare return variable
			AccountTransport Ftmp = new AccountTransport();
			Ftmp.PrimaryClient = new AccountPrimaryClientTransport();
			Ftmp.PrimaryClient.ClientId = dummyClient.ClientId;
			Ftmp.PrimaryClient.Name = dummyClient.Name;
			Ftmp.PrimaryClient.Notes = dummyClient.Notes;
			Ftmp.PrimaryClient.Website = dummyClient.Website;
			Ftmp.PrimaryClient.PrimaryContact = dummyClient.Contacts[0];
			Ftmp.PrimaryClient.BankAccounts = new ObservableCollection<BankAccountTransport>();
			Ftmp.AccountInvoices = new ObservableCollection<AccountInvoiceTransport>();
			Ftmp.Notes = new ObservableCollection<AccountNoteTransport>();

			// Set account details
			Ftmp.AccountId = iAccountId;
			Ftmp.FRLReference = string.Format("FRL{0}", iAccountId.ToString().PadLeft(5, '0'));

			#region Set the client details
			if ((iAccountId >= 1) && (iAccountId <= 3))
			{

				// Set client details
				Ftmp.PrimaryClient.Name = "Browns";

				// Add contact
				Ftmp.PrimaryClient.PrimaryContact.AddressList = new ObservableCollection<ContactAddressTransport>();
				Ftmp.PrimaryClient.PrimaryContact.PointList = new ObservableCollection<ContactPointTransport>();

				// Set contact
				Ftmp.PrimaryClient.PrimaryContact.Title = "Mr";
				Ftmp.PrimaryClient.PrimaryContact.FirstName = "Gary";
				Ftmp.PrimaryClient.PrimaryContact.Surname = "Brown";

				Ftmp.PrimaryClient.PrimaryContact.Notes = "Notes notes notes notes and notes.";

				// Set address				
				ContactAddressTransport address = new ContactAddressTransport();
				Ftmp.PrimaryClient.PrimaryContact.AddressList.Add(address);
				address.AddressLineA = "Unit 2";
				address.AddressLineB = "114 Roebuck Road";
				address.City = "Chessington";
				address.County = "Surrey";
				address.Postcode = "KT9 1EU";
				address.CountryCode = "UK";

				// Set points
				Ftmp.PrimaryClient.PrimaryContact.PointList.Add(new ContactPointTransport() { ContactPointId = Guid.NewGuid(), ContactPointType = (int)Definitions.eContactPointType.Email, Address = "gb@frl.co.uk" });
				Ftmp.PrimaryClient.PrimaryContact.PointList.Add(new ContactPointTransport() { ContactPointId = Guid.NewGuid(), ContactPointType = (int)Definitions.eContactPointType.Mobile, Address = "07771936693" });

			}
			else if ((iAccountId >= 4) && (iAccountId <= 6))
			{

				// Set client details
				Ftmp.PrimaryClient.Name = "Casey Construction";

				// Add contact
				Ftmp.PrimaryClient.PrimaryContact.AddressList = new ObservableCollection<ContactAddressTransport>();
				Ftmp.PrimaryClient.PrimaryContact.PointList = new ObservableCollection<ContactPointTransport>();

				// Set contact
				Ftmp.PrimaryClient.PrimaryContact.Title = "Ms";
				Ftmp.PrimaryClient.PrimaryContact.FirstName = "Gina";
				Ftmp.PrimaryClient.PrimaryContact.Surname = "Casey";

				// Set address				
				ContactAddressTransport address = new ContactAddressTransport();
				Ftmp.PrimaryClient.PrimaryContact.AddressList.Add(address);
				address.AddressLineA = "85 Tolworth Rise South";
				address.City = "Tolworth";
				address.County = "Surrey";
				address.Postcode = "KT8 5QQ";
				address.CountryCode = "UK";

				// Set points
				Ftmp.PrimaryClient.PrimaryContact.PointList.Add(new ContactPointTransport() { ContactPointId = Guid.NewGuid(), ContactPointType = (int)Definitions.eContactPointType.Email, Address = "gc@frl.co.uk" });
				Ftmp.PrimaryClient.PrimaryContact.PointList.Add(new ContactPointTransport() { ContactPointId = Guid.NewGuid(), ContactPointType = (int)Definitions.eContactPointType.Mobile, Address = "07771936693" });

			}
			else if ((iAccountId >= 7) && (iAccountId <= 10))
			{

				// Set client details
				Ftmp.PrimaryClient.Name = "Salmon Homes";

				// Add contact
				Ftmp.PrimaryClient.PrimaryContact.AddressList = new ObservableCollection<ContactAddressTransport>();
				Ftmp.PrimaryClient.PrimaryContact.PointList = new ObservableCollection<ContactPointTransport>();

				// Set contact
				Ftmp.PrimaryClient.PrimaryContact.Title = "Mr";
				Ftmp.PrimaryClient.PrimaryContact.FirstName = "John";
				Ftmp.PrimaryClient.PrimaryContact.Surname = "Gacy";

				Ftmp.PrimaryClient.PrimaryContact.Notes = "Notes notes notes notes notes notes notes notes notes notes notes notes notes notes notes notes and notes.";

				// Set address				
				ContactAddressTransport address = new ContactAddressTransport();
				Ftmp.PrimaryClient.PrimaryContact.AddressList.Add(address);
				address.AddressLineA = "777 SE 20TH ST";
				address.AddressLineB = "SUITE 150";
				address.City = "Fort Lauderdale";
				address.County = "Florida";
				address.Postcode = "FL 33316";
				address.CountryCode = "US";

				// Set points
				Ftmp.PrimaryClient.PrimaryContact.PointList.Add(new ContactPointTransport() { ContactPointId = Guid.NewGuid(), ContactPointType = (int)Definitions.eContactPointType.Email, Address = "gb@frl.co.uk" });
				Ftmp.PrimaryClient.PrimaryContact.PointList.Add(new ContactPointTransport() { ContactPointId = Guid.NewGuid(), ContactPointType = (int)Definitions.eContactPointType.Mobile, Address = "07771936693" });

			}
#if DEBUG
			else
				Debug.Assert(false);
#endif // #if DEBUG
			#endregion Set the client details

			// Set the client bank accounts
			BankAccountTransport bankAccount = new BankAccountTransport();
			bankAccount.AccountName = "Phonebook Current";
			bankAccount.AccountNo = "24681357";
			bankAccount.BankAccountId = 1;
			bankAccount.BankName = "Barlays Bank";
			bankAccount.CurrencyCode = Money.SterlingCode;
			bankAccount.SortCode = "56-12-78";
			bankAccount.Address = new ContactAddressTransport();
			bankAccount.Address.AddressLineA = "2 London Road";
			bankAccount.Address.AddressLineB = "Eastside Instustrial Estate";
			bankAccount.Address.City = "Slough";
			bankAccount.Address.Postcode = "SL1 3RT";
			bankAccount.Address.County = "Berks";
			bankAccount.Address.CountryCode = "UK";
			Ftmp.PrimaryClient.BankAccounts.Add(bankAccount);
			if ((iAccountId % 2) == 0)
			{
				bankAccount = new BankAccountTransport();
				bankAccount.AccountName = "Speaker Savings";
				bankAccount.AccountNo = "817283988";
				bankAccount.BankAccountId = 2;
				bankAccount.BankName = "Lloyds Bank";
				bankAccount.CurrencyCode = Money.YenCode;
				bankAccount.SortCode = "12-34-99";
				bankAccount.Address = new ContactAddressTransport();
				bankAccount.Address.AddressLineA = "Unit 45";
				bankAccount.Address.AddressLineB = "Highstreet";
				bankAccount.Address.City = "Maidenhead";
				bankAccount.Address.Postcode = "SL56 3EG";
				bankAccount.Address.County = "Berks";
				bankAccount.Address.CountryCode = "UK";
				Ftmp.PrimaryClient.BankAccounts.Add(bankAccount);
			}

			#region Debtor contact details
			Ftmp.DebtorContacts = new ObservableCollection<ContactTransport>();
			ContactTransport debtorContact = new ContactTransport();
			debtorContact.ContactId = 1;
			Ftmp.DebtorContacts.Add(debtorContact);				
			debtorContact.AddressList = new ObservableCollection<ContactAddressTransport>();
			ContactAddressTransport debtorAddress = new ContactAddressTransport();
			debtorAddress.AddressType = (int)Definitions.eContactAddressType.Default;
			debtorContact.AddressList.Add(debtorAddress);
			debtorContact.PointList = new ObservableCollection<ContactPointTransport>();
			if(iAccountId == 1)
			{
				Ftmp.DebtorName = "Mr Clarkson	Consumer";
				Ftmp.DebtorClientRef = "CLARK1";
				debtorContact.Title = "Mr";
				debtorContact.FirstName = "B";
				debtorContact.Surname = "Clarkson";
				debtorContact.PointList.Add( new ContactPointTransport() { ContactPointId=Guid.NewGuid(), ContactPointType=(int)Definitions.eContactPointType.Mobile, Address="07771936693"} );
				debtorContact.PointList.Add( new ContactPointTransport() { ContactPointId=Guid.NewGuid(), ContactPointType=(int)Definitions.eContactPointType.Email, Address="gb@frl.co.uk"} );
				debtorAddress.AddressLineA = "85 Berry Hill";
				debtorAddress.City = "Huddersfield";
				debtorAddress.Postcode = "HD4 6HD";
				debtorAddress.CountryCode = "UK";
			}
			else if(iAccountId == 2)
			{
				Ftmp.DebtorName = "Magic Shop Ltd";
				Ftmp.DebtorClientRef = "MAGIC45";
				//Ftmp.DebtorWebsite = "www.magic.com";
				debtorContact.Title = "Ms";
				debtorContact.FirstName = "Sally";
				debtorContact.Surname = "Webb";
				debtorContact.PointList.Add( new ContactPointTransport() { ContactPointId=Guid.NewGuid(), ContactPointType=(int)Definitions.eContactPointType.Email, Address="gc@frl.co.uk"} );
				debtorAddress.AddressLineA = "302 High Street";
				debtorAddress.City = "Oxford";
				debtorAddress.County = "Oxfordshire";
				debtorAddress.Postcode = "OX9 5JJ";
				debtorAddress.CountryCode = "UK";
			}
			else if (iAccountId == 3)
			{
				Ftmp.DebtorName = "Jack Black";
				Ftmp.DebtorClientRef = "JACKBLACK";
				//Ftmp.DebtorWebsite = "www.jackbl.co.uk";
				debtorContact.Title = "Mr";
				debtorContact.FirstName = "M";
				debtorContact.Surname = "Wilkinson";
				debtorContact.PointList.Add(new ContactPointTransport() { ContactPointId = Guid.NewGuid(), ContactPointType = (int)Definitions.eContactPointType.Mobile, Address = "07771936693" });
				debtorContact.PointList.Add(new ContactPointTransport() { ContactPointId = Guid.NewGuid(), ContactPointType = (int)Definitions.eContactPointType.Phone, Address = "02081691859" });
				debtorContact.PointList.Add(new ContactPointTransport() { ContactPointId = Guid.NewGuid(), ContactPointType = (int)Definitions.eContactPointType.Email, Address = "gb@frl.co.uk" });
				debtorAddress.AddressLineA = "450 Black Avenue";
				debtorAddress.City = "Milton Keynes";
				debtorAddress.Postcode = "MK21 9XX";
				debtorAddress.CountryCode = "UK";
			}
			else if (iAccountId == 4)
			{
				Ftmp.DebtorName = "Atlantis Yachts";
				Ftmp.DebtorClientRef = "65986";
				debtorContact.Title = "Ms";
				debtorContact.FirstName = "Helen";
				debtorContact.Surname = "Jones";
				debtorContact.PointList.Add(new ContactPointTransport() { ContactPointId = Guid.NewGuid(), ContactPointType = (int)Definitions.eContactPointType.Mobile, Address = "07825687979" });
				debtorContact.PointList.Add(new ContactPointTransport() { ContactPointId = Guid.NewGuid(), ContactPointType = (int)Definitions.eContactPointType.Phone, Address = "033942264466" });
				debtorContact.PointList.Add(new ContactPointTransport() { ContactPointId = Guid.NewGuid(), ContactPointType = (int)Definitions.eContactPointType.Email, Address = "stinky2708@gmail.com" });
				debtorAddress.AddressLineA = "2401 PGA Blvd";
				debtorAddress.AddressLineB = "Suite 192";
				debtorAddress.AddressLineC = "Palm Beach Gardens";
				debtorAddress.County = "Florida";
				debtorAddress.Postcode = "FL33410";
				debtorAddress.CountryCode = "US";
			}
			else if (iAccountId == 5)
			{
				Ftmp.DebtorName = "Jones Sweets";
				Ftmp.DebtorClientRef = "MM968";
				debtorContact.Title = "Mr";
				debtorContact.Surname = "Ham";
				debtorContact.PointList.Add(new ContactPointTransport() { ContactPointId = Guid.NewGuid(), ContactPointType = (int)Definitions.eContactPointType.Mobile, Address = "07889601838" });
				debtorContact.PointList.Add(new ContactPointTransport() { ContactPointId = Guid.NewGuid(), ContactPointType = (int)Definitions.eContactPointType.Phone, Address = "0448596352" });
				debtorContact.PointList.Add(new ContactPointTransport() { ContactPointId = Guid.NewGuid(), ContactPointType = (int)Definitions.eContactPointType.Email, Address = "stinky2708@hotmail.co.uk" });
				debtorAddress.AddressLineA = "Bonner STR. 26";
				debtorAddress.City = "Munchen";
				debtorAddress.Postcode = "D-80804";
				debtorAddress.CountryCode = "DE";
			}
			else if (iAccountId == 6)
			{
				Ftmp.DebtorName = "Timber Sales";
				Ftmp.DebtorClientRef = "TIM6659";
				debtorContact.Title = "Mr";
				debtorContact.FirstName = "Kevin";
				debtorContact.Surname = "Slater";
				debtorContact.PointList.Add(new ContactPointTransport() { ContactPointId = Guid.NewGuid(), ContactPointType = (int)Definitions.eContactPointType.Mobile, Address = "07590808158" });
				debtorContact.PointList.Add(new ContactPointTransport() { ContactPointId = Guid.NewGuid(), ContactPointType = (int)Definitions.eContactPointType.Phone, Address = "02089462886" });
				debtorContact.PointList.Add(new ContactPointTransport() { ContactPointId = Guid.NewGuid(), ContactPointType = (int)Definitions.eContactPointType.Email, Address = "richardpsalmon@hotmail.com" });
				debtorAddress.AddressLineA = "Woods Farm";
				debtorAddress.AddressLineB = "Bicester Lane";
				debtorAddress.City = "Slough";
				debtorAddress.Postcode = "SL4 8OPI";
				debtorAddress.CountryCode = "UK";
			}
			else if (iAccountId == 7)
			{
				Ftmp.DebtorName = "Home Sweet Home Limited";
				Ftmp.DebtorClientRef = "HOM999";
				debtorContact.Surname = "Sirs";
				debtorContact.PointList.Add(new ContactPointTransport() { ContactPointId = Guid.NewGuid(), ContactPointType = (int)Definitions.eContactPointType.Mobile, Address = "07590808158" });
				debtorContact.PointList.Add(new ContactPointTransport() { ContactPointId = Guid.NewGuid(), ContactPointType = (int)Definitions.eContactPointType.Phone, Address = "02076593859" });
				debtorContact.PointList.Add(new ContactPointTransport() { ContactPointId = Guid.NewGuid(), ContactPointType = (int)Definitions.eContactPointType.Email, Address = "stinky2708@gmail.com" });
				debtorAddress.AddressLineA = "Restfield House";
				debtorAddress.City = "Harrow";
				debtorAddress.County = "Middlesex";
				debtorAddress.Postcode = "HX9 2LL";
				debtorAddress.CountryCode = "UK";
			}
			else if (iAccountId == 8)
			{
				Ftmp.DebtorName = "Mr John Victors Consumer";
				Ftmp.DebtorClientRef = "VIC864";
				debtorContact.Title = "Mr";
				debtorContact.FirstName = "John";
				debtorContact.Surname = "Victors";
				debtorContact.PointList.Add(new ContactPointTransport() { ContactPointId = Guid.NewGuid(), ContactPointType = (int)Definitions.eContactPointType.Mobile, Address = "07825687979" });
				debtorContact.PointList.Add(new ContactPointTransport() { ContactPointId = Guid.NewGuid(), ContactPointType = (int)Definitions.eContactPointType.Phone, Address = "01142659269" });
				debtorContact.PointList.Add(new ContactPointTransport() { ContactPointId = Guid.NewGuid(), ContactPointType = (int)Definitions.eContactPointType.Email, Address = "gb@frl.co.uk" });
				debtorAddress.AddressLineA = "Flat 9";
				debtorAddress.AddressLineB = "Jelly House";
				debtorAddress.AddressLineC = "Waterside Walk";
				debtorAddress.City = "Hounslow";
				debtorAddress.Postcode = "H96 6NN";
				debtorAddress.CountryCode = "UK";
			}
			else if (iAccountId == 9)
			{
				Ftmp.DebtorName = "Sweet Factory";
				Ftmp.DebtorClientRef = "SAM964";
				debtorContact.Title = "Mr";
				debtorContact.FirstName = "Gary";
				debtorContact.Surname = "Samson";
				debtorContact.PointList.Add(new ContactPointTransport() { ContactPointId = Guid.NewGuid(), ContactPointType = (int)Definitions.eContactPointType.Mobile, Address = "07889601838" });
				debtorContact.PointList.Add(new ContactPointTransport() { ContactPointId = Guid.NewGuid(), ContactPointType = (int)Definitions.eContactPointType.Phone, Address = "01942649185" });
				debtorContact.PointList.Add(new ContactPointTransport() { ContactPointId = Guid.NewGuid(), ContactPointType = (int)Definitions.eContactPointType.Email, Address = "richardsalmon@hotmail.com" });
				debtorAddress.AddressLineA = "15 North Road";
				debtorAddress.AddressLineB = "Lancing West";
				debtorAddress.County = "Sussex";
				debtorAddress.Postcode = "BN15 9AH";
				debtorAddress.CountryCode = "UK";
			}
			else if (iAccountId == 10)
			{
				Ftmp.DebtorName = "Melts Ltd";
				Ftmp.DebtorClientRef = "M6985";
				debtorContact.Title = "MR";
				debtorContact.FirstName = "D";
				debtorContact.Surname = "Simons";
				debtorContact.PointList.Add(new ContactPointTransport() { ContactPointId = Guid.NewGuid(), ContactPointType = (int)Definitions.eContactPointType.Mobile, Address = "07590808158" });
				debtorContact.PointList.Add(new ContactPointTransport() { ContactPointId = Guid.NewGuid(), ContactPointType = (int)Definitions.eContactPointType.Phone, Address = "02089468561" });
				debtorContact.PointList.Add(new ContactPointTransport() { ContactPointId = Guid.NewGuid(), ContactPointType = (int)Definitions.eContactPointType.Email, Address = "gb@frl.co.uk" });
				debtorAddress.AddressLineA = "16 Sea Spray Avenue";
				debtorAddress.AddressLineB = "Shoreham";
				debtorAddress.Postcode = "BN43 5PR";
				debtorAddress.CountryCode = "UK";
			}
#if DEBUG
			else
				Debug.Assert(false);
#endif // #if DEBUG
			#endregion Debtor contact details

			#region Invoice details
			if (iAccountId == 1)
			{
				Ftmp.AccountInvoices.Add(new AccountInvoiceTransport() { AccountInvoiceId = 1, InvoiceNo = "225698", InvoiceDate = new DateTime(2010, 2, 1), Amount = new CurrencyTransport() { Amount = 555.33M, CurrencyCode = Money.SterlingCode } });
			}
			else if (iAccountId == 2)
			{
				Ftmp.AccountInvoices.Add(new AccountInvoiceTransport() { AccountInvoiceId = 1, InvoiceNo = "568694", InvoiceDate = new DateTime(2010, 6, 16), Amount = new CurrencyTransport() { Amount = 6085.35M, CurrencyCode = Money.EuroCode } });
				Ftmp.AccountInvoices.Add(new AccountInvoiceTransport() { AccountInvoiceId = 2, InvoiceNo = "468912", InvoiceDate = new DateTime(2010, 7, 30), Amount = new CurrencyTransport() { Amount = 6598.00M, CurrencyCode = Money.USDollarCode } });
			}
			else if (iAccountId == 3)
			{
				Ftmp.AccountInvoices.Add(new AccountInvoiceTransport() { AccountInvoiceId = 1, InvoiceNo = "695", InvoiceDate = new DateTime(2009, 8, 1), Amount = new CurrencyTransport() { Amount = 99.86M, CurrencyCode = Money.USDollarCode } });
				Ftmp.AccountInvoices.Add(new AccountInvoiceTransport() { AccountInvoiceId = 2, InvoiceNo = "452", InvoiceDate = new DateTime(2009, 12, 9), Amount = new CurrencyTransport() { Amount = 65.98M, CurrencyCode = Money.USDollarCode } });
				Ftmp.AccountInvoices.Add(new AccountInvoiceTransport() { AccountInvoiceId = 3, InvoiceNo = "777", InvoiceDate = new DateTime(2010, 1, 1), Amount = new CurrencyTransport() { Amount = 45.78M, CurrencyCode = Money.USDollarCode } });
				Ftmp.AccountInvoices.Add(new AccountInvoiceTransport() { AccountInvoiceId = 4, InvoiceNo = "1525", InvoiceDate = new DateTime(2010, 2, 6), Amount = new CurrencyTransport() { Amount = 852.00M, CurrencyCode = Money.SterlingCode } });
			}
			else if (iAccountId == 4)
			{
				Ftmp.AccountInvoices.Add(new AccountInvoiceTransport() { AccountInvoiceId = 1, InvoiceNo = "BI43645", InvoiceDate = new DateTime(2008, 8, 19), Amount = new CurrencyTransport() { Amount = 1500.00M, CurrencyCode = Money.USDollarCode } });
				Ftmp.AccountInvoices.Add(new AccountInvoiceTransport() { AccountInvoiceId = 2, InvoiceNo = "USA44783", InvoiceDate = new DateTime(2008, 9, 24), Amount = new CurrencyTransport() { Amount = 2200.00M, CurrencyCode = Money.USDollarCode } });
				Ftmp.AccountInvoices.Add(new AccountInvoiceTransport() { AccountInvoiceId = 3, InvoiceNo = "USA45551", InvoiceDate = new DateTime(2008, 10, 23), Amount = new CurrencyTransport() { Amount = 2200.00M, CurrencyCode = Money.USDollarCode } });
				Ftmp.AccountInvoices.Add(new AccountInvoiceTransport() { AccountInvoiceId = 4, InvoiceNo = "BI52131", InvoiceDate = new DateTime(2009, 10, 12), Amount = new CurrencyTransport() { Amount = 2100.00M, CurrencyCode = Money.USDollarCode } });
			}
			else if (iAccountId == 5)
			{
				Ftmp.AccountInvoices.Add(new AccountInvoiceTransport() { AccountInvoiceId = 1, InvoiceNo = "MY51262", InvoiceDate = new DateTime(2009, 8, 31), Amount = new CurrencyTransport() { Amount = 1000.00M, CurrencyCode = Money.EuroCode } });
			}
			else if (iAccountId == 6)
			{
				Ftmp.AccountInvoices.Add(new AccountInvoiceTransport() { AccountInvoiceId = 1, InvoiceNo = "989", InvoiceDate = new DateTime(2009, 1, 1), Amount = new CurrencyTransport() { Amount = 106953.22M, CurrencyCode = Money.SterlingCode } });
				Ftmp.AccountInvoices.Add(new AccountInvoiceTransport() { AccountInvoiceId = 2, InvoiceNo = "522", InvoiceDate = new DateTime(2008, 12, 2), Amount = new CurrencyTransport() { Amount = 22598.00M, CurrencyCode = Money.SterlingCode } });
				Ftmp.AccountInvoices.Add(new AccountInvoiceTransport() { AccountInvoiceId = 3, InvoiceNo = "587", InvoiceDate = new DateTime(2009, 4, 6), Amount = new CurrencyTransport() { Amount = 1582.35M, CurrencyCode = Money.SterlingCode } });
				Ftmp.AccountInvoices.Add(new AccountInvoiceTransport() { AccountInvoiceId = 4, InvoiceNo = "521", InvoiceDate = new DateTime(2010, 11, 9), Amount = new CurrencyTransport() { Amount = 10777.08M, CurrencyCode = Money.SterlingCode } });
			}
			else if (iAccountId == 7)
			{
				Ftmp.AccountInvoices.Add(new AccountInvoiceTransport() { AccountInvoiceId = 1, InvoiceNo = "584/www/784", InvoiceDate = new DateTime(2009, 7, 5), Amount = new CurrencyTransport() { Amount = 12.98M, CurrencyCode = Money.SterlingCode } });
			}
			else if (iAccountId == 8)
			{
				Ftmp.AccountInvoices.Add(new AccountInvoiceTransport() { AccountInvoiceId = 1, InvoiceNo = "96/h45/65", InvoiceDate = new DateTime(2010, 7, 9), Amount = new CurrencyTransport() { Amount = 968.65M, CurrencyCode = Money.SterlingCode } });
				Ftmp.AccountInvoices.Add(new AccountInvoiceTransport() { AccountInvoiceId = 2, InvoiceNo = "658/LL5589", InvoiceDate = new DateTime(2010, 5, 9), Amount = new CurrencyTransport() { Amount = 568.00M, CurrencyCode = Money.SterlingCode } });
				Ftmp.AccountInvoices.Add(new AccountInvoiceTransport() { AccountInvoiceId = 3, InvoiceNo = "58438/115", InvoiceDate = new DateTime(2009, 1, 6), Amount = new CurrencyTransport() { Amount = 11.75M, CurrencyCode = Money.SterlingCode } });
			}
			else if (iAccountId == 9)
			{
				Ftmp.AccountInvoices.Add(new AccountInvoiceTransport() { AccountInvoiceId = 1, InvoiceNo = "5598", InvoiceDate = new DateTime(2009, 12, 5), Amount = new CurrencyTransport() { Amount = 698.55M, CurrencyCode = Money.SterlingCode } });
				Ftmp.AccountInvoices.Add(new AccountInvoiceTransport() { AccountInvoiceId = 1, InvoiceNo = "9685", InvoiceDate = new DateTime(2009, 8, 9), Amount = new CurrencyTransport() { Amount = 569.00M, CurrencyCode = Money.SterlingCode } });
			}
			else if (iAccountId == 10)
			{
				Ftmp.AccountInvoices.Add(new AccountInvoiceTransport() { AccountInvoiceId = 1, InvoiceNo = "8986", InvoiceDate = new DateTime(2010, 2, 2), Amount = new CurrencyTransport() { Amount = 69.45M, CurrencyCode = Money.SterlingCode } });
				Ftmp.AccountInvoices.Add(new AccountInvoiceTransport() { AccountInvoiceId = 1, InvoiceNo = "8596", InvoiceDate = new DateTime(2010, 9, 3), Amount = new CurrencyTransport() { Amount = 150.00M, CurrencyCode = Money.SterlingCode } });
				Ftmp.AccountInvoices.Add(new AccountInvoiceTransport() { AccountInvoiceId = 1, InvoiceNo = "9698", InvoiceDate = new DateTime(2010, 10, 1), Amount = new CurrencyTransport() { Amount = 250.00M, CurrencyCode = Money.SterlingCode } });
			}
#if DEBUG
			else
				Debug.Assert(false);
#endif // #if DEBUG
			#endregion Invoice details

			// Add notes
			for (int iNoteId = 1; iNoteId <= 10; iNoteId++)
			{

				// Generate timestamp
				DateTime dt = DateTime.Now.Subtract(new TimeSpan(iNoteId-1, 0, 5 * iNoteId, 0));

				// Get author
				string strUserDescription;
				int iFactor = (iNoteId * iAccountId) % 5;
				switch (iFactor)
				{
					case 0: strUserDescription = "Ted Bundy"; break;
					case 1: strUserDescription = "John Wayne Gacy III"; break;
					case 2: strUserDescription = "Robert Cod"; break;
					case 3: strUserDescription = "Gary Brown"; break;
					default: strUserDescription = "Gail Casey"; break;
				}

				// Add note
				Ftmp.Notes.Add(new AccountNoteTransport()
				{
					AccountNoteId = iNoteId,
					Timestamp = dt,
					UserDescription = strUserDescription,
					Narrative = "Bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla."
				});

			}



			// Return variable
			return Ftmp;

		}
#endif // #if USEFAKEDATA

#if USEFAKEDATA
		public static ChaseWorkspaceSupportData GetDummyChaseWorkspaceSupportData()
		{

			// Declare return variable
			ChaseWorkspaceSupportData Ftmp = new ChaseWorkspaceSupportData();

			// Add supporting object lists
			Ftmp.CurrentUser = CachedDataBase.GetDummaryUserSessionTransport(false);
			Ftmp.CountryMap = CachedDataBase.GetDummyCountryMap();
			Ftmp.ContactCounties = CachedDataBase.GetDummyContactCounties();
			Ftmp.ContactPositions = CachedDataBase.GetDummyContactPositions();
			Ftmp.ContactTitles = CachedDataBase.GetDummyContactTitles();
			Ftmp.TradingStyleMap = CachedDataBase.GetDummyTradingStyleMap();

			// Return variable
			return Ftmp;

		}
#endif // #if USEFAKEDATA

	}

}
